<form action="{:url()}" method="post" class="form_single">
  <div class="box">
    <div class="box-header with-border">
      <h3 class="box-title">价格预警设置</h3>
    </div>
    <div class="box-body">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label>产品</label>
            <span>（选择要设置预警的产品）</span>
            <select class="form-control" name="product_id">
              <option value="">请选择产品</option>
              {volist name="products" id="product"}
              <option value="{$product.id}" {if condition="($alert_info.product_id ?? '') == $product.id"}selected{/if}>{$product.name}</option>
              {/volist}
            </select>
          </div>
        </div>
        <div class="col-md-6">
          <div class="form-group">
            <label>预警类型</label>
            <span>（价格预警的类型）</span>
            <select class="form-control" name="alert_type">
              <option value="1" {if condition="($alert_info.alert_type ?? 1) == 1"}selected{/if}>价格上涨</option>
              <option value="2" {if condition="($alert_info.alert_type ?? 1) == 2"}selected{/if}>价格下跌</option>
              <option value="3" {if condition="($alert_info.alert_type ?? 1) == 3"}selected{/if}>价格变动</option>
            </select>
          </div>
        </div>

        <div class="col-md-6">
          <div class="form-group">
            <label>预警价格</label>
            <span>（触发预警的价格）</span>
            <input class="form-control" name="alert_price" placeholder="请输入预警价格" value="{$alert_info['alert_price']|default=''}" type="number" step="0.01">
          </div>
        </div>

        <div class="col-md-6">
          <div class="form-group">
            <label>预警幅度</label>
            <span>（价格变动百分比）</span>
            <input class="form-control" name="alert_percent" placeholder="请输入预警幅度" value="{$alert_info['alert_percent']|default='10'}" type="number" step="0.01">
          </div>
        </div>

        <div class="col-md-6">
          <div class="form-group">
            <label>通知方式</label>
            <span>（预警通知方式）</span>
            <select class="form-control" name="notify_type">
              <option value="1" {if condition="($alert_info.notify_type ?? 1) == 1"}selected{/if}>系统通知</option>
              <option value="2" {if condition="($alert_info.notify_type ?? 1) == 2"}selected{/if}>邮件通知</option>
              <option value="3" {if condition="($alert_info.notify_type ?? 1) == 3"}selected{/if}>短信通知</option>
            </select>
          </div>
        </div>

        <div class="col-md-6">
          <div class="form-group">
            <label>状态</label>
            <span>（预警状态）</span>
            <select class="form-control" name="status">
              <option value="1" {if condition="($alert_info.status ?? 1) == 1"}selected{/if}>启用</option>
              <option value="0" {if condition="($alert_info.status ?? 1) == 0"}selected{/if}>禁用</option>
            </select>
          </div>
        </div>

        <div class="col-md-12">
          <div class="form-group">
            <label>备注</label>
            <span>（预警设置的备注说明）</span>
            <textarea class="form-control" name="remark" rows="3" placeholder="请输入备注">{$alert_info['remark']|default=''}</textarea>
          </div>
        </div>
          
      </div>
    </div>
    <div class="box-footer">
      
      <input type="hidden" name="id" value="{$alert_info['id']|default='0'}"/>
        
      <button type="submit" class="btn btn-primary">保存</button>
      <button type="button" class="btn btn-default" onclick="layer.closeAll();">取消</button>
      
    </div>
  </div>
</form>

<script>
$(function() {
    // 设置下拉菜单默认值
    ob.setValue("alert_type", {$alert_info.alert_type ?? 1});
    ob.setValue("notify_type", {$alert_info.notify_type ?? 1});
    ob.setValue("status", {$alert_info.status ?? 1});
});
</script>